var express = require('express');
var router = express.Router();
var db = require('../config/db');
const cookieParser = require('cookie-parser');
var session = require('express-session');
var app=express();
app.use(cookieParser('express_cookie'));
app.use(session({
    secret:'express_cookie',
    resave: true,
    saveUninitialized:true,
    name:'testapp',
    cookie: {maxAge: 60 * 1000 * 30}//过期时间
}));


router.get('/', function(req, res, next) {
	console.log(req.query.name);
	var name = req.query.name;
	
	var result={};
	db.query('select * from user where name="'+name+'"')
	.then(data=>{
		console.log(data)
		result=data[0].id;
		//req.session.userInfo=name;
		res.json({list:data})
	})
	return
	
})
router.get('/userInfo',function (req,res) {
	console.log(req.session);
    // if(req.session.userInfo==undefined){
    //     //responseClient(res,200,0,'',req.session.userInfo)
    //     res.josn({status:200,session:req.session.userInfo})
    // }else{
    //     responseClient(res,200,1,'请重新登录',req.session.userInfo)
    // }
});
module.exports = router;